import 'package:flutter/material.dart';

class View2 extends StatefulWidget {
  var _name = 'qweqwe';
  @override
  State<StatefulWidget> createState() {
    return new View1State();
  }
}

class View1State extends State<View2> {
  int _num = 0;
  @override
  Widget build(BuildContext context) {
    return new Center(
      child: new Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          new Container(
            child: new Text('click ' + _num.toString() + ' times'),
          ),
          new Container(
            child: new Text('_name is ' + widget._name),
          ),
          new Container(
            padding: new EdgeInsets.all(10.0),
            decoration: new BoxDecoration(
              color: Colors.red,
              borderRadius: new BorderRadius.all(Radius.circular(6.0)),
            ),
            child: new GestureDetector(
              onTap: _onBtnTap,
              child: new Text('button', style: TextStyle(color: Colors.white),),
            ),
          ),
          new Container(
            child: new GestureDetector(
              onTap: () async{
                var res = await Navigator.of(context).pushNamed('other',  arguments: {'from': 'view2222'});
                print(res);// res可接收新打开的Other页面关闭时返回的数据
              },
              child: new Text('to other page'),
            ),
          ),
          new Container(
            width: 540.0,
            decoration: new BoxDecoration(
              color: Colors.red
            ),
            padding: EdgeInsets.all(30.0),
            child: new Text('qweqwe', style: new TextStyle(color: Colors.white)),
          ),
          new Container(
            child: new DefaultTextStyle(
              style: new TextStyle(
                color: Colors.red
              ),
              child: new Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: <Widget>[
                  new Text('qeqw1'),
                  new Text('qeqw2'),
                  new Text('qeqw3', style: new TextStyle(color: Colors.grey)),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }

  void _onBtnTap() {
    setState(() {
      _num ++;
      widget._name = 'has change';
    });
  }
}